/* 全局样式 */
body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: #333;
}

/* 导航栏 */
.navbar {
    background: linear-gradient(135deg, 
    white 0%, 
    white 30%,  
    #3e92cc 60%, 
    #3e92cc 100%
  );
    color: #fff;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar .logo {
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar .logo svg {
    width: 24px;
    height: 24px;
}

.navbar .buttons button {
    background-color: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    margin-left: 15px;
    cursor: pointer;
    transition: opacity 0.3s;
    padding: 6px 12px;
    border-radius: 4px;
}

.navbar .buttons button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 主体布局 */
.main-container {
    display: flex;
    flex: 1;
    padding: 20px;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    height: calc(100vh - 64px);
    box-sizing: border-box;
    overflow: hidden;
}

/* 左侧历史记录 */
.history-panel {
    width: 280px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 16px;
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
}

.history-panel h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #374151;
    font-weight: 600;
    padding: 8px 4px;
}

.history-items {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
}

.history-item {
    background-color: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.history-item.active {
    background-color: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.new-chat-button, .clear-history-button {
    width: 100%;
    padding: 10px;
    background-color: #2196F3;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    text-align: center;
    margin-bottom: 12px;
    font-weight: 500;
}

.new-chat-button:hover, .clear-history-button:hover {
    background-color: #3a7ae8;
}

.clear-history-button {
    background-color: #f43f5e;
    margin-bottom: 0;
}

.clear-history-button:hover {
    background-color: #e11d48;
}

/* 中间聊天区域 */
.chat-panel {
    height: 100%;
    flex: 1;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    max-width: 90%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.ai {
    align-self: flex-start;
}

.message-content {
    max-width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
    position: relative;
}

.message.user .message-content {
    background-color: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background-color: #f9fafb;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    background-color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #6b7280;
    font-weight: bold;
}

.message.user .message-avatar {
    background-color: #bfdbfe;
    color: #1e40af;
    margin-right: 0;
    margin-left: 12px;
}

.chat-input-container {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.chat-input {
    display: flex;
    gap: 12px;
    align-items: center;
    overflow-y: auto;
}

.chat-input textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    line-height: 1.5;
    background-color: #fff;
}

.chat-input textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-input textarea:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

.chat-input button {
    padding: 10px 16px;
    background-color: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    height: 50px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-input button:hover {
    background-color: #1d4ed8;
}

.chat-input button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

/* 右侧 AI 百科 */
.ai-encyclopedia {
    width: 280px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 16px;
    border: 1px solid #e5e7eb;
    overflow-y: auto;
}

.ai-encyclopedia h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #374151;
    font-weight: 600;
    padding: 8px 4px;
}

.role-option {
    background-color: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e5e7eb;
}

.role-option:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.role-option.active {
    background-color: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

/* 打字指示器样式 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
    margin-bottom: 16px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    display: inline-block;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        padding: 12px;
    }
    
    .history-panel, .ai-encyclopedia {
        width: auto;
        margin-bottom: 12px;
        max-height: 200px;
    }
    
    .history-items {
        max-height: 120px;
    }
}

/* Markdown 样式增强 */
.message-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message.user .message-content pre {
    background-color: rgba(255, 255, 255, 0.2);
}

.message-content code {
    font-family: 'Courier New', monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
}

.message.user .message-content code {
    background-color: rgba(255, 255, 255, 0.2);
}

.message-content p {
    margin: 8px 0;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content blockquote {
    border-left: 3px solid #ddd;
    padding-left: 12px;
    margin: 8px 0;
    color: #666;
}

.message.user .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
}